#@HplusLayout()
#define css()
<link href="#(res_path)/hplus/css/plugins/webuploader/webuploader.css" type="text/css" rel="stylesheet">
#end
#define cssStyle()
<style>
#filePicker .webuploader-pick {border-radius:0 3px 3px 0;display: block;height: 34px;width:80px;font-size: 13px;padding: 0;line-height: 34px;}	
</style>
#end
#define content()
<div style="padding:15px">
	<form class="form-horizontal"> 
		<div class="form-group">
			<label class="col-xs-2 control-label" style="text-align: right;padding-top: 7px;">文件路径：</label>
			<div class="col-xs-9">
				<div class="input-group">
			  	<input type="text" class="form-control" id="filepath" readonly="readonly"/>
			    <span class="input-group-btn"><div id="filePicker">选择文件</div></span>
				</div>
			</div>
		</div>
		<div class="form-group">
    	<div class="col-xs-9 col-xs-offset-2">
      	<button type="button" onclick="submitPath();" class="btn btn-success">确定</button>
      </div>
    </div>
	</form>
</div>
#end
#define js()
<script src="#(res_path)/hplus/js/plugins/webuploader/webuploader.min.js"></script>
#end
#define jsFunction()
<script>
 	var uploader;
 	$(function(){
 		uploader = WebUploader.create({
 			server: "doUpload",
 			pick: "#filePicker",
 			auto:true,
 			chunked:false,
 			threads:1,
 			fileVal:"filedata",
 			formData:{directory:"#(directory??"other")",upload_type:"#(upload_type??"")"}
		});
 		
 		uploader.on( "fileQueued", function( file ) {
 			layer.load(0, {shade: [0.5,'#fff']});
 		});
 		uploader.on( "uploadSuccess", function( file,response) {
 			if(response.result=="success"){
 	  		$("#filepath").val(response.server+response.filePath);
 			}
 		});

		uploader.on( "uploadComplete", function( file ) {
			layer.closeAll();
		});

  	uploader.on( "uploadError", function( file ,reason ) {
  		layer.alert("上传失败！",{icon:2});
  	});
 	});
 	
 	function submitPath(){
 		var path = $("#filepath").val();
 		if(path==""){
 			layer.alert("请先选择文件！");
 		}
 		var input = $("##(input??"NULL")", window.parent.document);
 		if(input.size()>0){
 			input.val(path);
 		}
 		window.parent.layer.closeAll();
 	}
</script>
#end